//
//  KyNavViewController.swift
//  KyBase
//
//  Created by fangyukui on 2017/10/16.
//  Copyright © 2017年 fangyukui. All rights reserved.
//

import UIKit

class KyNavViewController: UINavigationController {
    override func viewDidLoad() {
        super.viewDidLoad()
        
        //隐藏系统navigationBar,但任然用系统UINavigationController管理控制器
        navigationBar.isHidden = true
        
      
        
        // Do any additional setup after loading the view.
    }
    
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        KyLog(message: childViewControllers)
        KyLog(message: viewControllers)
        
        
        //隐藏底部tabBar
        if childViewControllers.count > 0{
            viewController.hidesBottomBarWhenPushed = true
            var  title = "返回"
            if childViewControllers.count==1 {
                title = childViewControllers.first?.title ?? "返回"
            }
            
            if  let vc = viewController as? KyBaseViewController {
                
                vc.kyNaVItem.leftBarButtonItem = UIBarButtonItem(title:title, target: self, action: #selector(back),isBack:true)
            }
            
    
        }
        super.pushViewController(viewController, animated: animated)
        
        
    }
    @objc private func back(){
        popViewController(animated: true)
        
    }


}
